cmake_minimum_required(VERSION 3.18)

project(test_cross_compile_link_error C)

add_library(subb SHARED b.c)
if(CMAKE_CROSSCOMPILING)
    # 交叉编译用PRIVATE会链接失败，只有用PUBLIC才能链接成功
    target_link_libraries(subb PRIVATE ${PROJECT_SOURCE_DIR}/sub/libsub_arm64.so)
else()
    # x86本地编译即使用PRIVATE也不会失败
    target_link_libraries(subb PRIVATE ${PROJECT_SOURCE_DIR}/sub/libsub_x64.so)
endif()

add_executable(main main.c)
target_link_libraries(main subb)
